package com.jianglin.controller;

import com.github.pagehelper.PageInfo;
import com.jianglin.model.ComplaintType;
import com.jianglin.service.IComplaintTypeService;
import io.swagger.annotations.Api;

import io.swagger.annotations.ApiOperation;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
/**
 *
 *
 * @author liyijia
 */
@Api(tags = {"投诉类型管理"})
@CrossOrigin(origins="http://localhost:5500")
@RestController
@RequestMapping("/complainttype")
@SuppressWarnings("SpellCheckingInspection")
public class ComplaintTypeController {


    @Resource
    private IComplaintTypeService complaintTypeService;

    @GetMapping("/queryAll")
    public List<ComplaintType> queryAll() {
        return complaintTypeService.queryType();
    }

    @ApiOperation(value = "新增")
    @PostMapping
    public int add(@RequestBody ComplaintType complaintType) {
        return complaintTypeService.add(complaintType);
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("{id}")
    public int delete(@PathVariable("id") Integer id) {
        return complaintTypeService.delete(id);
    }

    @ApiOperation(value = "更新")
    @PutMapping
    public int update(@RequestBody ComplaintType complaintType) {
        return complaintTypeService.updateData(complaintType);
    }

    @ApiOperation(value = "查询分页数据")
    @GetMapping
    public PageInfo<ComplaintType> findListByPage(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer pageSize) {
        return complaintTypeService.findListByPage(page, pageSize);
    }

    @ApiOperation(value = "id查询")
    @GetMapping("{id}")
    public ComplaintType findById(@PathVariable Integer id) {
        return complaintTypeService.findById(id);
    }
}
